import { create } from "zustand";
import { persist } from "zustand/middleware";

const useStore = create(
  persist(
    (set) => ({
      count: 0,
      setCount: (value) => set({ count: value }),
    }),
    {
      name: "count-key",
    }
  )
);

export default function TestJotai5() {
  const count = useStore((state) => state.count);
  const setCount = useStore((state) => state.setCount);

  return (
    <div>
      count: {count}
      <button onClick={() => setCount(count + 1)}>加一</button>
    </div>
  );
}
